#pragma once


#define GRAVITY -3500.0f



#include "iobject.h"
#include "IListener.h"

class CBaseObject;
struct tAnimInfo
{
	unsigned int unAnimIndex;
	int nCurrFrame;
	float fTimePerFrame;
	CBaseObject* pOwner;
};

class CEvent;


class CBaseObject :	public IObject, public IListener
{
public:
	CBaseObject(void);
	virtual ~CBaseObject(void);

	/* IObject interface */
	virtual void Update( float fElapsedTime );
	virtual void Render( void );
	virtual void AddRef( void );
	virtual void Release( void );
	virtual bool CheckCollision( IObject* tOther );
	virtual RECT GetBaseRect( void );
	virtual RECT GetRect( void );

	/* IListener interface */
	virtual void HandleEvent( CEvent* pEvent );

	tVector3D	GetVelocity( void );


	/* Accessors */
	tVector3D	 GetPosition( void ) const			{	return m_tPosition;			}
	tVector3D	 GetRelativePosition( void ) const  {	return m_tRelativePosition;	}
	tAnimInfo&	 GetAnimInfo( void )				{	return m_tAnimInfo;			}
	unsigned int GetHeight( void ) const			{	return m_unHeight;			}
	unsigned int GetWidth( void ) const				{	return m_unWidth;			}
	bool		 IsGrounded( void ) const			{	return m_bIsGrounded;		}
	bool		 IsVisible( void ) const			{	return m_bIsVisible;		}
	char		 GetFacingDirection( void ) const	{	return m_cFacingDirection;	}

	/* Mutators */
	/* Position in world space */
	void		SetPosition( tVector3D tPos )		{	m_tPosition = tPos;			}
	void		SetPosition( float fX, float fY, float fZ );
	void		SetXPosition( float fX )			{	m_tPosition.fX = fX;		}
	void		SetYPosition( float fY )			{	m_tPosition.fY = fY;		}
	void		SetZPosition( float fZ )			{	m_tPosition.fZ = fZ;		}

	/* Position relative to camera */
	void		SetRelativePosition( tVector3D tPos )		{	m_tRelativePosition = tPos;			}
	void		SetRelativePosition( float fX = 0.0f, float fY = 0.0f, float fZ = 0.0f );
	void		SetRelativeXPosition( float fX )			{	m_tRelativePosition.fX = fX;		}
	void		SetRelativeYPosition( float fY )			{	m_tRelativePosition.fY = fY;		}
	void		SetRelativeZPosition( float fZ )			{	m_tRelativePosition.fZ = fZ;		}

	void		SetAnimInfo( tAnimInfo tInfo)		{	m_tAnimInfo = tInfo;		}

	void		SetHeight( unsigned int nHeight )	{	m_unHeight = nHeight;		}
	void		SetWidth( unsigned int nWidth )		{	m_unWidth = nWidth;			}
	void		SetGrounded( bool b	)				{	m_bIsGrounded = b;			}
	void		SetVisible( bool b )				{	m_bIsVisible = b;			}

	void		SetObjType( int nType )				{	m_nObjType = nType;			}


	enum OBJTYPE { OBJ_BASE, OBJ_CHAR, OBJ_PROJ };

private:

	int				m_nObjType;

	/* Position in world space */
	tVector3D		m_tPosition;

	/* Position on screen */
	tVector3D		m_tRelativePosition;

	tAnimInfo		m_tAnimInfo;

	unsigned int	m_unRefCount;

	unsigned int	m_unWidth;
	unsigned int	m_unHeight;

	char			m_cFacingDirection;
	bool			m_bIsGrounded;
	bool			m_bIsVisible;

};

